const rl = require('readline').createInterface({ input: process.stdin })
const inter = rl[Symbol.asyncIterator]()
const readline = async () => (await inter.next()).value

void (async function () {
	/* 发动机总个数 手动启动个数 */
	const [n, e] = (await readline()).split(' ').map(Number)
	
	// 发动机编号对应启动时刻 默认是1001
	const arr = Array(n).fill(1001)
	
	for (let i = 0; i < e; i ++) {
		/* 启动时刻 发动机编号 */
		const [t, p] = (await readline()).split(' ').map(Number)
		
		arr[p] = t
	}
	
	for (let i = 0; i < arr.length; i ++) {
		for (let j = 0; j < arr.length; j ++) {
			// i编号发动机启动时刻
			const it = arr[i]
			// 关联到j编号发动机的时间
			// 正向
			const time = Math.abs(j - i)
			// 反向
			const otherTime = arr.length - time
			
			const mix = Math.min(time, otherTime)
			
			arr[j] = Math.min(arr[j], arr[i] + mix)
		}
	}
	
	console.log(arr)
	let max = 0
	const indexArr = []
	
	for (let i = 0; i < arr.length; i ++) {
		if (arr[i] > max) {
			// indexArr = []
			// 清空数组可以使用 .length = 0
			indexArr.length = 0
			max = arr[i]
		}
		
		
		if (arr[i] === max) {
			indexArr.push(i)
		}
	}
	
	console.log(indexArr.length)
	console.log(indexArr.sort((a, b) => a - b))
	
})()
